package vn.gq.udv.comic;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class SplashActivity extends FragmentActivity {

	private boolean active = true;
	private int splashTime = 1500;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);
		
		ImageView splash = (ImageView) findViewById(R.id.imageview);
		splash.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					active = false;
				}
				return true;
			}
		});
		
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
					int waited = 0;
					while (active && waited<splashTime) {
						Thread.sleep(100);
						waited += 100;
					}
				} catch(InterruptedException e) {
					
				} finally {
					Intent intent = new Intent(SplashActivity.this, HomeActivity.class);
					startActivity(intent);
					finish();
				}
			}
		}).start();
	}

	@Override
	public void onBackPressed() {
	}

}
